﻿namespace Example
{
    using System;

    public sealed class HttpClient
    {
        private Uri _uri;

        public HttpClient(string uri)
            : this(new Uri(uri, UriKind.RelativeOrAbsolute))
        {
        }

        public HttpClient(Uri uri)
        {
            Uri = uri;
        }

        public Uri Uri
        {
            get
            {
                return _uri;
            }

            set
            {
                if (null == value)
                {
                    throw new ArgumentNullException("value");
                }
                else if (!value.IsAbsoluteUri)
                {
                    throw new ArgumentOutOfRangeException("value");
                }
                else if (!"http".Equals(value.Scheme, StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentOutOfRangeException("value");
                }

                _uri = value;
            }
        }
    }
}